YZYZ.Admin.Scenic.editWin 		= null;
YZYZ.Admin.Scenic.editForm 		= null;
YZYZ.Admin.Scenic.editRegionCB 	= null;
YZYZ.Admin.Scenic.editLevelCB 	= null;
YZYZ.Admin.Scenic.showEditWin=function(){
	if(!YZYZ.Admin.Scenic.editWin){
		YZYZ.Admin.Scenic.editLevelCB=new Ext.form.ComboBox({  
	         id: 'editLevel', 
	         name:'editLevel', 
	         allowBlank: false,  
	         fieldLabel: "显示级别",  
	         hiddenName: 'hideditLevel',  
	         displayField: 'name',  
	         valueField: 'id',  
	         typeAhead: true,  
	         triggerAction: 'all',  
	         store: YZYZ.levelData.levelStore,  
	         mode: 'local',
	         width:200 ,
	         editable:false
 		});
		YZYZ.Admin.Scenic.editRegionCB=new Ext.form.ComboBox({  
	         id: 'editRegion', 
	         name:'editRegion', 
	         allowBlank: false,  
	         fieldLabel: "地区",  
	         hiddenName: 'hidEditRegion',  
	         displayField: 'name',  
	         valueField: 'id',  
	         typeAhead: true,  
	         triggerAction: 'all',  
	         store: YZYZ.Admin.Scenic.groupStore,  
	         mode: 'local',
	         width:200 ,
	         editable:false
 		});
 		YZYZ.Admin.Scenic.editForm=new Ext.form.FormPanel({
			labelWidth:120,
			autoScroll:true,
			width:450,
			height:200,
			region:'center',
			labelAlign:'right',
			bodyStyle:'padding-top:10px',
			items:[{
				fieldLabel:'名称',
				xtype:'textfield',
				width:200,
				maxLength:20,
				id:'editName'	
			},{
				fieldLabel:'地址',
				xtype:'textfield',
				width:200,
				maxLength:40,
				id:'editLocation'	
			},YZYZ.Admin.Scenic.editLevelCB,
			YZYZ.Admin.Scenic.editRegionCB]
		});
		YZYZ.Admin.Scenic.editWin=new Ext.Window({
			title:'编辑景区',
			layout:'border',
			width:450,
			height:200,
			modal:true,
			closable:true,
			closeAction:'hide',
			items:[YZYZ.Admin.Scenic.editForm],
			buttons:[{
				text:'提交',
				width:60,
				handler:YZYZ.Admin.Scenic.editSubmit
			},{
				text:'关闭',
				width:60,
				handler:function(){YZYZ.Admin.Scenic.editWin.hide();}
			}]
		});
	}
	YZYZ.Admin.Scenic.editWin.show();
	var rec = YZYZ.Admin.Scenic.grid.getSelectionModel().getSelected();
	Ext.getCmp("editName").setValue(rec.get("name"));
	Ext.getCmp("editLocation").setValue(rec.get("location"));
	Ext.getCmp("editLevel").setValue(rec.get("level"));
	Ext.getCmp("editRegion").setValue(rec.get("ownerId"));

};
YZYZ.Admin.Scenic.editSubmit=function(){
	var name 	= Ext.getCmp("editName").getValue();
	var location=Ext.getCmp("editLocation").getValue();
	var level	=Ext.getCmp("editLevel").getValue();
	var ownerId	=Ext.getCmp("editRegion").getValue();
		if(Ext.isEmpty(name)){
		YZYZ.Curtain.alert("请填写名称");
		Ext.getCmp("editName").markInvalid();
		return;
	}
	if(name.length > 20){
		YZYZ.Curtain.alert("名称长度应小于20");
		Ext.getCmp("editName").markInvalid();
		return;
	}
	if(Ext.isEmpty(location)){
		YZYZ.Curtain.alert("请填写地址");
		Ext.getCmp("editLocation").markInvalid();
		return;
	}
	if(name.length > 40){
		YZYZ.Curtain.alert("地址长度应小于40");
		Ext.getCmp("editLocation").markInvalid();
		return;
	}
	if(Ext.isEmpty(ownerId)){
		YZYZ.Curtain.alert("请选择分组");
		Ext.getCmp("editRegion").markInvalid();
		return;
	}
	YZYZ.Curtain.msg("系统处理中....");
	Ext.Ajax.request( {
		url		: Ext.get("editUrl").dom.value,
		timeout	: 30000,
		method	: 'POST',
		params	: {
			name 		:  name,
			location    : location,
			level		: level,
			ownerId 	: ownerId,
			scenicId 	: YZYZ.Admin.Scenic.grid.getSelectionModel().getSelected().get("id")
		},
		success : function(result, request) {
			result = Ext.util.JSON.decode(result.responseText);
			if(result.code == YZYZ.success){
				YZYZ.Curtain.msg("修改成功");
				var rec = YZYZ.Admin.Scenic.grid.getSelectionModel().getSelected();
				rec.set("name",name);
				rec.set("location",location);
				rec.set("level",level);
				rec.set("ownerId",ownerId);
				YZYZ.Admin.Scenic.grid.getStore().commitChanges();
				YZYZ.Admin.Scenic.editWin.hide();			
			}
			else {
				YZYZ.Curtain.alert(result.message);
			}
		},
		failure : function(result, request) {
			YZYZ.Curtain.alert("操作失败！程序错误或网络故障");
		}
	});	
};